package com.project.user.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.project.common.utils.TimeUuidUtil;


import com.project.system.domain.GoodsInfo;
import com.project.system.domain.SysUser;
import com.project.system.mapper.GoodsInfoMapper;
import com.project.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.project.user.mapper.UserBrowseRecordMapper;
import com.project.user.domain.UserBrowseRecord;
import com.project.user.service.IUserBrowseRecordService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 浏览记录 服务层实现
 *
 * @author administrator
 */
@Service
public class UserBrowseRecordServiceImpl implements IUserBrowseRecordService {
    @Autowired
    private UserBrowseRecordMapper userBrowseRecordMapper;

    @Autowired
    private GoodsInfoMapper goodsInfoMapper;
    @Autowired
    private SysUserMapper userMapper;

    /**
     * 查询浏览记录列表
     *
     * @param userBrowseRecord 浏览记录信息
     * @return 浏览记录集合
     */
    @Override
    public List<UserBrowseRecord> selectUserBrowseRecordList(UserBrowseRecord userBrowseRecord) {
        return userBrowseRecordMapper.selectUserBrowseRecordList(userBrowseRecord);
    }

    /**
     * 新增浏览记录
     *
     * @param userBrowseRecord 浏览记录信息
     * @return 结果
     */
    @Override
    @Transactional
    public int insertUserBrowseRecord(UserBrowseRecord userBrowseRecord) {
        userBrowseRecord.setId(TimeUuidUtil.get16UUID());
        //添加同一用户同一餐饮之前的浏览记录
        userBrowseRecordMapper.deleteUserBrowseRecord(userBrowseRecord);
        return userBrowseRecordMapper.insertUserBrowseRecord(userBrowseRecord);
    }



    @Override
    public int deleteUserBrowseRecord(UserBrowseRecord browseRecord) {
        return userBrowseRecordMapper.deleteUserBrowseRecord(browseRecord);
    }

}
